﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using S7.Net;

namespace Puli.IndustrialCommunication.S7
{
    public class S7Communication
    {
        public Plc S7Plc { get; init; }
        public CpuType CpuType { get; set; }
        public string Ip { get; set; }
        public short Rack { get; set; }
        public short Slot { get; set; }
        public S7Communication()
        {
            S7Plc = new Plc(CpuType, Ip, Rack, Slot);
        }
        #region 连接plc
        /// <summary>
        /// 连接PLC
        /// </summary>
        /// <returns></returns>
        public bool Connect()
        {
            try
            {
                S7Plc.Open();
                return true;
            }
            catch (Exception)
            {
                throw;
            }

        }
        #endregion
        #region 读取数据
        ///// <summary>
        ///// 根据PLC变量获取数据
        ///// </summary>
        //public void GetValue()
        //{
           
        //}
        #endregion
    }
}
